/**
 * FileFind - ftp/shares indexing and search php engine
 * Module: agent-java
 * Description: Agent written in java language
 * Copyright (c) 2003-2010 Rage Steel, www.gt2.ru
 * ----------------------------------------------
 * $Id$
 */
package ru.ffind.agent.model;

import ru.ffind.common.model.Directory;


/**
 * 
 * Interface for listing storage
 *
 * @author Rage Steel
 *
 */
public interface ListingStorage {

	/**
	 * 
	 * Add directory contents
	 * 
	 * @param absolutePath absolute path to the directory
	 * @param contents directory contents
	 */
	void put(String absolutePath, Directory contents);

//	/**
//	 * 
//	 * Get directory by the absolute path
//	 * 
//	 * @param absolutePath
//	 * @return
//	 * 
//	 */
//	Directory get(String absolutePath);
	
	/**
	 * 
	 * Get directory by the absolute path and remove it from the listing
	 * 
	 * @param absolutePath absolute path to the directory
	 * @return Directory or null if directory is not found
	 * 
	 */
	Directory getAndRemove(String absolutePath);
	
	/**
	 * 
	 * Get directory by the absolute path and remove it from the listing
	 * If directory is not exists and scanning is not complete - retry after retryTimeout milliseconds
	 * FIXME There should be another way: add path to waiting list and after path addition - return found value
	 * FIXME Another idea with staying with timeouts - create decorator for ListingStorage that does this timeouts
	 * 
	 * @param absolutePath
	 * @return
	 */
	Directory getAndRemoveWithWait(String absolutePath, long retryTimeout);
	
	/**
	 * 
	 * Return status of scanning completion
	 * 
	 * @return true if all scanning is complete and there is no more data in listing expected
	 * 
	 */
	boolean isScanComplete();
	
	long getFilesCount();

}